package com.briup.bookstore.common.constant;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

/**
 * 订单状态常量类
 */
@Getter
@RequiredArgsConstructor
public enum OrderConstant {
    /**
     * 已创建未支付
     */
    CREATED_UNPAID(1, "已创建未支付"),
    /**
     * 已支付未发货
     */
    PAID_UNSHIPPED(2, "已支付未发货"),
    /**
     * 已发货未确认
     */
    SHIPPED_UNCONFIRMED(3, "已发货未收货"),
    /**
     * 已确认已完成
     */
    CONFIRMED_COMPLETED(4, "已收货"),
    /**
     * 已取消
     */
    CANCELED(5, "已关闭（只能取消关闭未支付的订单）");

    private final int status;
    private final String message;

    public static String getMessageByStatus(int status) {
        for (OrderConstant orderConstant : OrderConstant.values()) {
            if (orderConstant.getStatus() == status) {
                return orderConstant.getMessage();
            }
        }
        return null;
    }
}
